package pl.edu.agh.uddiProxy;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;

import pl.edu.agh.uddiProxy.AuthenticationHelper;
import pl.edu.agh.uddiProxy.dao.DAOHelper;
import pl.edu.agh.uddiProxy.types.User;


public class UserManager implements Job {

	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("admin", "admin");
		AuthenticationHelper.login(authentication);
		
		for (User user : DAOHelper.getUserDAO().getAll()) {
			user.getServiceList().clear();
			DAOHelper.getUserDAO().update(user);
		}
		
		AuthenticationHelper.logout(authentication);		
	}

}
